<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>template</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            background-color: #bbff;
        }
    </style>
</head>
<body>
    <!-- template的元素是不会被渲染的 -->
    <template id="tem">
        <p>hahaha</p>
    </template>
    <div id="div"></div>

    <script>
        // 通过content获取template中的内容，转移到div下就可以显示了
        var template = document.querySelector("#tem");
        var div = document.getElementById("div")
        var fragment = template.content;
        div.appendChild(fragment)
    </script>
</body>
</html>